hostUrl = "/zinvest",
    uid = "";
var isRouterValid = function () {
    var e = sessionStorage.getItem("uid");
    e && "" !== e || (location.hash = "login")
};
$.ajaxSetup({
    cache: !1,
    timeout: 3e4,
    beforeSend: function (e) {
        $.showLoading(),
            e.setRequestHeader("R-Token", sessionStorage.getItem("token")),
            e.setRequestHeader("uid", sessionStorage.getItem("uid"))
    },
    complete: function (e, t) {
        $.hideLoading();
        var a = e.getResponseHeader("pragma");
        if (a) {
            var r = a.split(",");
            r && 2 === r.length && sessionStorage.setItem("token", r[1])
        }
    },
    error: function (e, t, a) {      
        if (500 === e.status) {
            $.toptip("服务器错误，请联系管理员！", "error")
        } else if (e.status == 0) {
            if ("timeout" === t) {
                $.toptip("请求超时，请稍后重试！", "error")
            } else {
                $.toptip("服务器未启动，请联系管理员！", "error")
            }
        } else if (401 === e.status) {
            $.toptip("登陆信息无效或过期，即将重新登录", "error"),
                setTimeout(function () {
                    location.hash = "login"
                }, 1e3)
        }
    }
}),
    $(function () {
        vipspa.start({
            view: "#ui-view",
            errorTemplateId: "#error",
            router: {
                trade: {
                    templateUrl: "views/trade.html",
                    controller: "js/app/trade.js"
                },
                "trade#tab4": {
                    templateUrl: "views/trade.html#tab4",
                    controller: "js/app/trade.js"
                },
                login: {
                    templateUrl: "views/login.html",
                    controller: "js/app/login.js"
                },
                register: {
                    templateUrl: "views/register.html",
                    controller: "js/app/register.js"
                },
                "reset-pw": {
                    templateUrl: "views/reset-pw.html",
                    controller: "js/app/reset-pw.js"
                },
                "pass-manage": {
                    templateUrl: "views/pass-manage.html",
                    controller: "js/app/pass-manage.js"
                },
                "modify-pw": {
                    templateUrl: "views/modify-pw.html",
                    controller: "js/app/modify-pw.js"
                },
                "add-pay-pw": {
                    templateUrl: "views/add-pay-pw.html",
                    controller: "js/app/add-pay-pw.js"
                },
                "modify-pay-pw": {
                    templateUrl: "views/modify-pay-pw.html",
                    controller: "js/app/modify-pay-pw.js"
                },
                "reset-pay-pw": {
                    templateUrl: "views/reset-pay-pw.html",
                    controller: "js/app/reset-pay-pw.js"
                },
                "bank-info": {
                    templateUrl: "views/bank-info.html",
                    controller: "js/app/bank-info.js"
                },
                "edit-bank": {
                    templateUrl: "views/edit-bank.html",
                    controller: "js/app/edit-bank.js"
                },
                capital: {
                    templateUrl: "views/capital.html",
                    controller: "js/app/capital.js"
                },
                defaults: "login"
            }
        })
    });
